@layout("/common/_container.html"){
<style>
    ul{padding: 0;margin: 0;}
    #ulBox{display: flex} #ulBox>li li{margin: 15px 0}
    #ulBox>li{flex: 1;border: 1px solid #dddddd;border-radius: 10px;padding: 10px 20px;}
    #ulBox>li span{display: inline-block ; width: 120px;}
    .frameBox{width: 60%;height: 32px;padding-left: 10px;border: 1px solid #cccccc;border-radius: 5px;}
    .btnBox{margin-top: 15px;}
    .btnBox>button{margin: 0;  color: white;  background: #2b6594;  width: 100px;  font-size: 1em;border: 1px solid #cccccc}
</style>

<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal" id="updateInfoForm">
            <div style="display: none">
                <input type="hidden" id="oneChannelValue" value="">
                <input type="hidden" id="twoChannelValue" value="">
                <input type="hidden" id="thrChannelValue" value="">
                <input type="hidden" id="reservationsId" value="${reservationsId}">
                <input type="hidden" id="idValue" value="${id}">
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div>
                        <ul id="ulBox">
                            <li style="margin-right: 20px;">
                                <ul>
                                    <li>
                                        <label><input type="radio" name="programme" value="方案一">原市场渠道</label>
                                    </li>
                                    <li>
                                        <span>建档人</span>
                                        <input type="text"  id="name" value="${reservationsInfo.archiving}" class="frameBox" value="" readonly="readonly">
                                    </li>
                                    <li>
                                        <span>一级渠道</span>
                                        <input  id="sOneChannel"  value="${info.sOneChannel}" class="frameBox" readonly="readonly"></input>
                                    </li>

                                    <li>
                                        <span>二级渠道</span>
                                        <input  id="sTwoChannel"  value="${info.sTwoChannel}" class="frameBox" readonly="readonly"></input>
                                    </li>
                                    <li>
                                        <span>三级渠道</span>
                                        <input  id="sThrChannel"  value="${info.sThrChannel}" class="frameBox" readonly="readonly"></input>
                                    </li>
                                </ul>
                            </li>
                            <li>
                                <ul>
                                    <li>
                                        <label><input type="radio" name="programme" value="方案二">已修改渠道</label>
                                    </li>
                                    <li>
                                        <span>提交门店</span>
                                        <input type="text" id="outpatientName" value="${reservationsInfo.outpatientName}" class="frameBox" value="" readonly="readonly">
                                    </li>
                                    <li>
                                        <span>一级渠道</span>
                                        <input  id="oneChannel" value="${info.oneChannel}" name="oneChannel"  class="frameBox" readonly="readonly"></input>
                                    </li>
                                    <li>
                                        <span>二级渠道</span>
                                        <input  id="twoChannel" value="${info.twoChannel}" name="twoChannel" class="frameBox" readonly="readonly"></input>
                                    </li>
                                    <li>
                                        <span>三级渠道</span>
                                        <input  id="thrChannel" value="${info.thrChannel}" name="thrChannel" class="frameBox" readonly="readonly"></input>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                    <div style="margin: 15px 0;">
                        <p>备注</p>
                        <textarea name="remarks" id="remarks" class="frameBox" style="width: 100%;height: 50px;"></textarea>
                    </div>
                </div>
                <!--<div class="col-sm-12">
                    <div>
                        <label><input type="radio" name="agree" value="同意">同意</label>
                        <label><input type="radio" name="agree" value="不同意">不同意</label>
                    </div>
                </div>-->
                <div class="col-sm-12">
                    <div class="btnBox">
                        @if(shiro.hasPermission("/super_no")){
                        <button type="button" class="btn" id="ensure">提交</button>
                        @}
                        <button type="button" class="btn" id="cancel" style="background: #999999" >取消</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    /**
     * 渠道修改提交
     */
    $("#ensure").click(function () {
        var name = $("#name").val();                   //建档人
        var sOneChannel = $("#sOneChannel").val();     //原一级渠道
        var sTwoChannel = $("#sTwoChannel").val();     //原二级渠道
        var sThrChannel = $("#sThrChannel").val();     //原三级渠道
        var oneChannel = $("#oneChannel").val();       //一级渠道
        var twoChannel = $("#twoChannel").val();       //二级渠道
        var thrChannel = $("#thrChannel").val();       //三级渠道
        var remarks = $("#remarks").val();             //备注
        var outpatientName = $("#outpatientNameValue").val();             //门诊
        var reservationsId = $("#reservationsId").val();
        var id = $("#idValue").val();
        var programme = $("input[name='programme']:checked").val();   //方案
        // var agree = $("input[name='agree']:checked").val();   //是否同意
//        if(agree == "" || agree == null){
//            alert("请选择是否同意此方案！");
//            return;
//        }

        if (programme == "" || programme == null) {
            alert("请选择一个方案！")
        } else {
            if (programme == "方案一") {
                $.ajax({
                    url: Feng.ctxPath + "/reservations/updateModity3",
                    type: "post",
                    data: {
                         reservationsId: reservationsId, id: id, remarks: remarks
                    },
                    success: function (data) {
                        Feng.success('操作成功!');
                        $("#cancel").click();
                    },
                    error: function (data) {
                        alert('内部故障!');
                    }
                });
            } else if (programme == "方案二") {
                $.ajax({
                    url: Feng.ctxPath + "/reservations/updateModity1",
                    type: "post",
                    data: {
                        reservationsId: reservationsId, id: id,
                        oneChannel: oneChannel, twoChannel: twoChannel,
                        thrChannel: thrChannel, remarks: remarks
                    },
                    success: function (data) {
                        Feng.success('操作成功!');
                        $("#cancel").click();
                    },
                    error: function (data) {
                        alert('内部故障!');
                    }
                });
            }
        }
    });
    $("#cancel").click(function () {
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    })

</script>
@}
